package com.oim.fx.ui.forget;

import com.only.fx.OnlyPopupOver;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;

public class AccountPanel extends BorderPane {

	BorderPane rootPane = new BorderPane();

	StackPane box = new StackPane();
	VBox baseBox = new VBox();
	Label textLabel = new Label();
	TextField textField = new TextField();
	Button button = new Button();
	OnlyPopupOver over = new OnlyPopupOver();//提示
	Label overLabel = new Label("账号不能为空！");

	public AccountPanel() {
		initComponent();
		iniEvent();
	}

	private void initComponent() {
		this.setCenter(box);
		// this.setBottom(button);

		button.setText("下一步");
		textLabel.setText("请输入账号");
		textField.setPromptText("账号");

		baseBox.setAlignment(Pos.TOP_CENTER);
		baseBox.getChildren().add(textLabel);
		baseBox.getChildren().add(textField);
		baseBox.getChildren().add(button);

		box.getChildren().add(baseBox);
		
		over.setContentNode(overLabel);
	}

	private void iniEvent() {

	}

	public boolean verify() {
		String answer = textField.getText();
		boolean mark = true;
		if (null == answer || "".equals(answer)) {
			over.show(textField);
			textField.requestFocus();
			mark = false;
		} else {
			mark = true;
		}
		return mark;
	}

	public void setOnNextAction(EventHandler<ActionEvent> value) {
		button.setOnAction(value);
	}

	public String getAccount() {
		return textField.getText();
	}
}
